package com.qingcheng.service.impl;

import com.qingcheng.service.goods.CategoryService;
import com.qingcheng.service.goods.SkuService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义类实现InitializingBen接口，服务器启动即加载
 */
@Component
public class Init implements InitializingBean {
    @Autowired
    private CategoryService categoryService;

    @Autowired
    private SkuService skuService;
    /**
     * 定义方法，当服务器启动时即加载
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        //在服务器加载时将分类加载进redis中
        categoryService.saveCategoryToRedis();
        //在服务器加载时将价格加载进redis
        skuService.savePriceToRedis();
    }
}
